package uestc.lj.gulishop.member.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import uestc.lj.common.utils.R;
import uestc.lj.gulishop.member.service.MemberService;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author:Crazlee
 * @Date:2021/6/22
 */
@Controller
public class MemberWebController {

    @Autowired
    private MemberService memberService;

    /**
     * 支付成功后，跳转到用户的订单页
     *
     * @return
     */
    @GetMapping("/memberOrder.html")
    public String memberOrder(@RequestParam(value = "pageNum", defaultValue = "1") Long pageNum,
                              @RequestParam(value = "size", defaultValue = "3") Long size,
                              Model model, HttpServletRequest request) {

        //查出当前登录用户的所有订单列表数据
        Map<String, Object> map = new HashMap<>();
        map.put("page", pageNum);
        map.put("limit", size);
        R list = memberService.memberOrder(map);
        System.out.println("=========>" + list);
        model.addAttribute("orders", list);
        return "orderList";
    }
}
